﻿
using System;
using System.Reflection;

namespace Spring.PureMVC.Adapters
{
    internal class RegisterCommandAdapter
    {
        private object _command;
        public object Command
        {
            set
            {
                _command = value;
                RegisterCommand();
            }
            private get { return _command; }
        }

        private object _facade;
        public object Facade
        {
            set
            {
                _facade = value;
                RegisterCommand();

            }
            private get { return _facade; }
        }

        private string _notificationName;
        public string NotificationName
        {
            set
            {
                _notificationName = value;
                RegisterCommand();
            }
            private get { return _notificationName; }
        }

        private void RegisterCommand()
        {
            if (Command == null || Facade == null || NotificationName == null) return;
            Facade.GetType().GetMethod("RegisterCommand", new[] { NotificationName.GetType(), Command.GetType() })
.Invoke(Facade, new[] { NotificationName, Command });
        }


    }
}
